<?php
class b_question_type
{
    public function add_default_type()//add cau hoi khi m?i ch?y
    {
        global $DB;
        $rs = $DB->get_records('b_question_type');
        if(count($rs) == 0){
            $type['id'] = 1;
            $type['name'] = get_string('short_ques', 'local_blackboxsurvey');
            $type['status'] = 0;
            $DB->insert_record('b_question_type', $type);
            
            $type['id'] = 2;
            $type['name'] = get_string('multi_multi_ques', 'local_blackboxsurvey');
            $DB->insert_record('b_question_type', $type);

            $type['id'] = 3;
            $type['name'] = get_string('multi_single_ques', 'local_blackboxsurvey');
            $DB->insert_record('b_question_type', $type);
            
            $type['id'] = 4;
            $type['name'] = get_string('yesno_ques', 'local_blackboxsurvey');
            $DB->insert_record('b_question_type', $type);
        }
        /*for($i = 1;$i <=150; $i++)
        {
            //$insert['id'] = $i;
            $insert['subject'] = $i;
            $insert['teacher'] = 2;
            $DB->insert_record('teacher_subject', $insert);
        }*/
    }
    
    public function load_question_type()//load t?t c? loai cau h?i
    {
        global $DB;
        $rs = $DB->get_records('b_question_type');
        $options = array();
		foreach($rs as $r) {
			//parent option
			$options[$r->id] = $r->name;
		}
        return $options;
    }
    
    public function get_question_type()
    {
        global $DB;
        $rs = $DB->get_records('b_question_type');
        return $rs;
    }
}
?>